import apiClient from './http'

export const todoService = {
  // 任务相关接口
  async getTasks(params = {}) {
    return apiClient.get('/tasks', { params })
  },
  
  async getTaskById(id) {
    return apiClient.get(`/tasks/${id}`)
  },
  
  async createTask(task) {
    return apiClient.post('/tasks', task)
  },
  
  async updateTask(id, updates) {
    return apiClient.patch(`/tasks/${id}`, updates)
  },
  
  async deleteTask(id) {
    return apiClient.delete(`/tasks/${id}`)
  },
  
  async batchUpdateTasks(ids, completed) {
    return apiClient.patch('/tasks/batch-update', { ids, completed })
  },
  
  // 分类相关接口
  async getCategories() {
    return apiClient.get('/categories')
  },
  
  async createCategory(category) {
    return apiClient.post('/categories', category)
  },
  
  async updateCategory(id, updates) {
    return apiClient.patch(`/categories/${id}`, updates)
  },
  
  async deleteCategory(id) {
    return apiClient.delete(`/categories/${id}`)
  },
  
  // 标签相关接口
  async getTags() {
    return apiClient.get('/tags')
  },
  
  async createTag(tag) {
    return apiClient.post('/tags', tag)
  },
  
  async updateTag(id, updates) {
    return apiClient.patch(`/tags/${id}`, updates)
  },
  
  async deleteTag(id) {
    return apiClient.delete(`/tags/${id}`)
  },
  
  // 统计相关接口
  async getTaskStatistics(params = {}) {
    return apiClient.get('/statistics/summary', { params })
  },
  
  async getProductivityTrend(params = {}) {
    return apiClient.get('/statistics/completion-trend', { params })
  },
  
  async getCategoryDistribution(params = {}) {
    return apiClient.get('/statistics/category-distribution', { params })
  }
}